/*****************************************************************
 * created by lei.he on 2020/07/28 by headle file
 *****************************************************************/
const CryptoJS = require('crypto-js')

 exports.HandleLogs = (str,obj) => {
    if(!!obj){
        console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>${str} start`)
        console.log(obj)
        console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>${str} end`)
    } else {
        console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>${str}`)
    }
 }
 /**
  * MD5 加密
  * @param {string} str 
  */
 exports.CrpytoMD5 = (str) => {
    return CryptoJS.MD5(str).toString().toLocaleUpperCase()
 }
 /**
  * AES 加密
  * @param {string} str 加密的字段
  * @param {string} key 秘钥
  */
 exports.CrpytoAES = (str,key) => {
    let bytes = CryptoJS.AES.encrypt(str,key).toString()
    return bytes
 }
 /**
  * AES 解密
  * @param {string} str 解密的字段
  * @param {string} key 秘钥
  */
 exports.UnCrpytoAES = (str,key) => {
     let bytes = CryptoJS.AES.decrypt(str,key);
     return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
 }